<template>
  <view>
    <view>
       <navigator url="/pages/faultform/faultform" open-type="navigate"> 
         <view style="background-color: #55aaff; color: #fff; text-align: center; padding: 8px; margin: 20px; border-radius: 10px;"> 
		 新增故障报修
         </view>
      </navigator> 
     </view> 
	<view>
	  <navigator url="/pages/FaultRequestRepairClose/FaultRequestRepairClose" open-type="navigate">
	    <view style="background-color: #55aaff; color: #fff; text-align: center; padding: 8px; margin: 20px; border-radius: 10px;">
	      故障报修销令
	    </view>
	 </navigator>
	</view>
    
	<template>
	   <view v-for="(repair, index) in faultList" :key="index">
		   <navigator :url="`/pages/FaultRequestRepairClose/FaultRequestRepairClose?id=${repair.id}`"> 
	    <uni-card :is-shadow="false">
	      <view slot="title" class="card-title">单号: {{ repair.formcode }}</view>
	      <uni-list>
	      	<!-- <uni-list-item title="状态" :rightText="repair.status" />
			<uni-list-item title="故障等级" :rightText="repair.faultLevel" />
			<uni-list-item title="故障类型" :rightText="repair.faultType" />
			<uni-list-item title="专业" :rightText="array1[repair.major]" />
			<uni-list-item title="线路" :rightText="array2[repair.line]" />
			<uni-list-item title="上/下行" :rightText="repair.upDownLine" />
			<uni-list-item title="区间(始)" :rightText="repair.segmentBeginning" />
			<uni-list-item title="区间(终)" :rightText="repair.segmentEnd" />
			<uni-list-item title="异常发生时间" :rightText="repair.abnormalOccurrenceTime" />
			<uni-list-item title="设备大类" :rightText="repair.deviceCategory" />
			<uni-list-item title="设备功能分类" :rightText="repair.deviceFunctionClassification" />
			<uni-list-item title="部件名称" :rightText="repair.componentName" />
			<uni-list-item title="故障详情" :rightText="repair.faultDetails" />
			<uni-list-item title="是否影响行车" :rightText="repair.affectNormalRunning" />
			<uni-list-item title="申报人" :rightText="repair.declareBy" />
			<uni-list-item title="申报时间" :rightText="repair.declareByDate" />
			<uni-list-item title="当前处理人" :rightText="repair.processBy" />
			<uni-list-item title="处理部门" :rightText="repair.processByOrg" /> -->
			<uni-list-item title="故障等级" :rightText="repair.faultLevel" />
			<uni-list-item title="线路" :rightText="array2[repair.line]" />
			<uni-list-item title="区间(始)" :rightText="repair.segmentBeginning" />
			<uni-list-item title="区间(终)" :rightText="repair.segmentEnd" />
			<uni-list-item title="当前处理人" :rightText="repair.processBy" />
			<uni-list-item title="处理部门" :rightText="repair.processByOrg" />
			<uni-list-item title="申报时间" :rightText="repair.declareByDate" />
	      </uni-list>
		</uni-card>
		</navigator>
	   </view>
	</template>
	<uni-pagination @change="getList" :page-size="pageSize" :total="total" :current="current"></uni-pagination>
  </view>
</template>

<script>

export default {
  data() {
    return {
     faultList:[],
	 pageSize:10,
	 total:0,
	 current:1,
	 // array1: ['变电','工务','通信','信号','接触轨'],
	 array2: ['十七号线','十三号线'],
    }
  },
  methods: {  
      getList(){
      	uni.request({
      		url: `http://localhost:82/faultRequestRepair/management/list?pageSize=${this.pageSize}&pageNum=${this.current}`, // 替换为实际的后端API地址
      		method: 'GET',
      		success: (res) => {
      			console.log(res.data);
      			this.total=res.data.total
      			this.faultList=res.data.rows
      		},
      		fail: (err) => {
      		   console.error('Failed to fetch data from backend:', err);
      		},
      	});
      },
	  },
	created() {
		this.getList(); // 在组件创建时从后端获取数据
	}

}
</script>

<style>
  .card-title {
    background-color: #3CB371;
    color: white;
    font-weight: bold;
    padding: 10px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }
  
  .text-left {
    text-align: left;
    margin-right: 1px;
  }
</style>
